/* 引入页面模板 */
/* import index from '../page/index.vue' */
/* import content from '../page/content.vue' */
/* 为使用懒加载，把组件定义成异步组件 */
/* http://blog.csdn.net/u013778905/article/details/53995628 */
const index = resolve => require(['../page/index.vue'], resolve)
const content = resolve => require(['../page/content.vue'], resolve)
const movieMsg = resolve => require(['../page/movieMsg.vue'], resolve)
const search = resolve => require(['../page/search.vue'], resolve)
const page404 = resolve => require(['../page/404.vue'], resolve)

/* scrollBehavior可以让应用像浏览器的原生表现一样，在按后退前进按钮时，简单让页面滚动到顶部或原来的位置 */
export const scrollBehavior = (to, from, savedPosition) => {
  if (savedPosition) {
    return savedPosition
  } else {
    return { x: 0, y: 0 }
  }
}

/* 配置路由 */
export const routes = [
  { path: '/home', name: 'home', component: index },
  { path: '/content', name: 'content', component: content },
  { path: '/movieMsg/:key', name: 'movieMsg', component: movieMsg },
  { path: '/search', name: 'search', component: search },
  { path: '/page404', name: 'page404', component: page404 },
  { path: '', redirect: '/home' }
]
